<template>
  <div class="father">
    <h2>我是父组件</h2>
    <h4>我有{{ car }}</h4>
    <h4>子给的玩具：{{ toy }}</h4>
    <!--父组件往子组件中传递一个属性car-->
    <Child :car="car" :sendToy="getToy" />
  </div>
</template>

<script setup lang="ts" name="Father">
import Child from "./Child.vue";
import { ref } from "vue";

let car = ref("奔驰");
let toy = ref("");

//子传父
function getToy(value: string) {
  toy.value = value;
}
</script>

<style scoped>
.father {
  background-color: rgb(168, 168, 168);
  padding: 20px;
  border-radius: 10px;
}
</style>
